<?php
namespace app\index\controller;

use think\Controller;
use think\Request;
use think\Session;
use app\index\model\StudentModel;
use app\index\model\TestModel;
use app\index\model\MarkModel;
use app\index\model\User;

class Indexs extends Controller
{

    function __construct() {

        parent::__construct();

        $isLogin = Session::get('isLogin');
        if (1 != $isLogin){
            return $this->redirect('/index/index');
        }
    }

    public function index()
    {
        $id = Session::get('nid');
        $data['id']= $id;
        return $this->fetch('/index/index',$data);

    }

    public function info()
    {
        $id = Session::get('nid');
        $data['id']= $id;
        $student = StudentModel::get($id);
        $data['student']  =  $student;

        return $this->fetch('/index/info', $data);
    }

    public function infos()
    {
        $admin = Session::get('nid');
       // $data['admin']= $admin;
        $mark = MarkModel::all(['admin'=>$admin]);
        $data['mark']  =  $mark;

        $id = Session::get('nid');
        $student = StudentModel::get($id);
        $data['student']  =  $student;

        return $this->fetch('/index/infos', $data);
    }


    public function logout()
    {
        Session::delete('isLogin');
        return $this->redirect('/index/index');
    }
}
